package com.mapull.primitive;

/**
 * @author Mapull
 * @date 2024-04-13
 */
public class SimpleByte {

    public static void main(String[] args) {
        byte b = 12;
        Byte bt1 = Byte.valueOf(b);
        Byte bt2 = Byte.valueOf("12");
        System.out.println(bt1 == bt2);
    }

    public static void main17(String[] args) {
        Byte bt1 = Byte.valueOf("110", 2);
        Byte bt2 = Byte.valueOf("22", 8);
        Byte bt3 = Byte.valueOf("1A", 16);
        Byte bt4 = Byte.valueOf("-2F", 16);
        System.out.println(bt1);
        System.out.println(bt2);
        System.out.println(bt3);
        System.out.println(bt4);
    }
    public static void main16(String[] args) {
        Byte bt1 = Byte.valueOf("1A");//java.lang.NumberFormatException: For input string: "1A"
        Byte bt2 = Byte.valueOf("Java");//java.lang.NumberFormatException: For input string: "Java"
        Byte bt3 = Byte.valueOf("");//java.lang.NumberFormatException: For input string: ""
    }
    public static void main15(String[] args) {
        Byte bt1 = Byte.valueOf("123");
        Byte bt2 = Byte.valueOf("-23");
        Byte bt3 = Byte.valueOf("+56");
        System.out.println(bt1);
        System.out.println(bt2);
        System.out.println(bt3);
    }
    public static void main14(String[] args) {
        byte b = 12;
        Byte value = Byte.valueOf(b);
        System.out.println(value);
    }

    public static void main13(String[] args) {
        Byte b1 = new Byte("123");
        long value = b1.longValue();
        System.out.println(value);
    }

    public static void main12(String[] args) {
        Byte b1 = new Byte("123");
        short value = b1.shortValue();
        System.out.println(value);
    }
    public static void main11(String[] args) {
        byte b = Byte.parseByte(""); //java.lang.NumberFormatException: For input string: ""
        byte b1 = Byte.parseByte("1F"); //java.lang.NumberFormatException: For input string: "1F"
        byte b2 = Byte.parseByte("234");//java.lang.NumberFormatException: Value out of range. Value:"234"
    }

    public static void main10(String[] args) {
        byte bt1 = Byte.parseByte("110", 2);
        byte bt2 = Byte.parseByte("123", 8);
        byte bt3 = Byte.parseByte("1F", 16);
        System.out.println(bt1);
        System.out.println(bt2);
        System.out.println(bt3);
    }

    public static void main9(String[] args) {
        byte bt1 = Byte.parseByte("23");
        byte bt2 = Byte.parseByte("023");
        byte bt3 = Byte.parseByte("-12");
        System.out.println(bt1);
        System.out.println(bt2);
        System.out.println(bt3);
    }

    public static void main8(String[] args) {
        // 十进制
        Byte bt1 = Byte.decode("23");
        Byte bt2 = Byte.decode("-23");
        // 八进制
        Byte bt3 = Byte.decode("023");
        // 十六进制三种写法
        Byte bt4 = Byte.decode("0X23");
        Byte bt5 = Byte.decode("0x23");
        Byte bt6 = Byte.decode("#23");
        System.out.println(bt1);
        System.out.println(bt2);
        System.out.println(bt3);
        System.out.println(bt4);
        System.out.println(bt5);
        System.out.println(bt6);
    }
    public static void main7(String[] args) {
        Byte b1 = 1;
        byte b2 = 1;
        boolean equals = b1.equals(b2);
        System.out.println(equals);
    }
    public static void main6(String[] args) {
        Byte b1 = new Byte("1");
        Byte b2 = new Byte("-2");
        Byte b3 = 1;
        boolean bool1 = b1.equals(b2);
        boolean bool2 = b1.equals(b3);
        boolean equals = b1.equals(null);
        System.out.println(bool1);
        System.out.println(bool2);
        System.out.println(equals);
    }
    public static void main5(String[] args) {
        Byte b1 = new Byte("1");
        int i = b1.compareTo(null);
    }
    public static void main4(String[] args) {
        Byte b1 = new Byte("1");
        Byte b2 = new Byte("-2");
        int compare1 = b1.compareTo(b2);
        System.out.println(compare1);
        Byte b3 = new Byte("99");
        int compare2 = b1.compareTo(b3);
        System.out.println(compare2);
    }

    public static void main3(String[] args) {
        byte maxValue = Byte.MAX_VALUE;
        byte minValue = Byte.MIN_VALUE;
        int size = Byte.SIZE;
        int bytes = Byte.BYTES;
        Class<Byte> type = Byte.TYPE;
        System.out.println(maxValue);
        System.out.println(minValue);
        System.out.println(size);
        System.out.println(bytes);
        System.out.println(type);
    }
    public static void main2(String[] args) {
        Byte b1 = new Byte("true"); //java.lang.NumberFormatException
        Byte b2 = new Byte("200"); //java.lang.NumberFormatException: Value out of range
        Byte b3 = new Byte(""); //java.lang.NumberFormatException: For input string: ""
    }

    public static void main1(String[] args) {
        byte b = 26;
        Byte b0 = new Byte(b);
        Byte b1 = new Byte("1");
        Byte b2 = new Byte("-2");
        Byte b3 = new Byte("100");
        System.out.println(b0);
        System.out.println(b1);
        System.out.println(b2);
        System.out.println(b3);
    }
}
